#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@crane-pc>
#
# Distributed under terms of the MIT license.

"""

"""

class SegmentTreeNode:
    def __init__(self, start, end):
        self.start, self.end = start, end
        self.left, self.right = None, None


class Solution:
    def build(self, start, end):
        # write your code here
        return self.rec_build(start, end)

    def rec_build(self, start, end):
        if start > end:
            return None

        root = SegmentTreeNode(start, end)
        if start == end:
            return root

        mid = (start + end) // 2

        root.left  = self.rec_build(start, mid)
        root.right = self.rec_build(mid+1, end)
        return root


def main():
    print("start main")
    s = Solution()
    ret = s.build(1, 5)
    print(ret.start, ret.end)
    print(ret.left.start, ret.left.end)
    print(ret.right.start, ret.right.end)
    print(ret.right.right.start, ret.right.right.end)
    print(ret.right.right.right)

if __name__ == "__main__":
    main()
